<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>示例1</title>
    <style>
        .red{
            color:red;
        }
    </style>
    <script>
        function setAttr(){
            const title = document.getElementById("title");
            title.setAttribute("class","red");
            title.setAttribute("title","hello world")
            title.setAttribute("abc","jack")
            title.setAttribute("id","title")
        }
        function showAttr(){
            const title = document.getElementById("title");
            console.log(title.getAttribute("class"))
            console.log(title.getAttribute("title"))
            console.log(title.getAttribute("abc"))
        }
    </script>
</head>
<body>
    <h1 id="title" title="你好">ACCP</h1>
    <button onclick="setAttr()">设置属性</button>
    <button onclick="showAttr()">打印属性</button>
</body>
</html>